export default {
    namespaced: true,
    state: {
        User: {}, // 用于存储用户相关信息，初始为空对象
        message: {
            show: false,
            type: '',
            content: ''
        }
    },
    mutations: {
        SET_MESSAGE(state, payload) {
            state.message.show = payload.show
            state.message.type = payload.type
            state.message.content = payload.content
        },
        CLEAR_LOGIN_DATA(state) {
            state.User = {};
        },
        SET_USER_DATA(state, data) {
            state.User = data;
            localStorage.setItem('userData', JSON.stringify(data));
        }
    },
    actions: {
        SET_DATA({ commit }, data) {
            // console.log(data)
            commit('SET_USER_DATA', data);
        },
        CLEAR_DATA({ commit }) {
            commit('CLEAR_LOGIN_DATA');
        }
    },
    getters: {
        getUserData(state) {
            return state.User;
        },
    },
};